﻿using System;

internal class Misc
{
    internal static bool debug;
    private static int nextRnd = 0;
    private static float[] rnd = new float[0x186a0];
    private static float rndret;

    internal static string bin16(int num)
    {
        return binN(num, 0x10);
    }

    internal static string bin8(int num)
    {
        return binN(num, 8);
    }

    internal static string binN(int num, int N)
    {
        char[] chArray = new char[N];
        for (int i = 0; i < N; i++)
        {
            chArray[(N - i) - 1] = ((num & 1) == 1) ? '1' : '0';
            num = num >> 1;
        }
        return new string(chArray);
    }

    internal static string binStr(long value_Renamed, int bitcount)
    {
        string str = "";
        for (int i = 0; i < bitcount; i++)
        {
            str = (((value_Renamed & (((int) 1) << i)) != 0L) ? "1" : "0") + str;
        }
        return str;
    }

    internal static string hex16(int i)
    {
        string str = Convert.ToString(i, 0x10);
        while (str.Length < 4)
        {
            str = "0" + str;
        }
        return str.ToUpper();
    }

    internal static string hex8(int i)
    {
        string str = Convert.ToString(i, 0x10);
        while (str.Length < 2)
        {
            str = "0" + str;
        }
        return str.ToUpper();
    }

    internal static string pad(string str, string padStr, int length)
    {
        while (str.Length < length)
        {
            str = str + padStr;
        }
        return str;
    }

    internal static int[] resizeArray(int[] array, int newSize)
    {
        int[] destinationArray = new int[newSize];
        Array.Copy(array, 0, destinationArray, 0, Math.Min(newSize, array.Length));
        return destinationArray;
    }
}

